import request from '@/utils/request'

// 创建活动
export function createActivity(data) {
  return request({
    url: 'activity/saveActivity.zepc',
    method: 'post',
    data
  })
}

// 修改活动详情
export function updateActivity(data) {
  return request({
    url: 'activity/updateActivity.zepc',
    method: 'post',
    data
  })
}

// 可报名
export function getActivityPublishList(data) {
  return request({
    url: '/activity/findApplyAc.zepc',
    method: 'post',
    data
  })
}

// 已报名
export function getActivityJoinList(data) {
  return request({
    url: '/activity/findAttendAc.zepc',
    method: 'post',
    data
  })
}

// 学生 查询全部活动
export function getActivityAllList(data) {
  return request({
    url: '/activity/findAllAc.zepc',
    method: 'post',
    data
  })
}

// 待验证
export function getActivityVerifyList(data) {
  return request({
    url: '/activity/unVerificationAc.zepc',
    method: 'post',
    data
  })
}

// 获取活动详情
export function getActivityDetail(id) {
  return request({
    url: '/activity/qureeyactivity.zepc',
    method: 'post',
    data: {
      AcId: id
    }
  })
}

// 活动报名 activity/savebm.zepc
export function joinActivity(id) {
  return request({
    url: '/activity/savebm.zepc',
    method: 'post',
    data: {
      AcId: id
    }
  })
}

// 删除活动
export function deleteActivity(id) {
  return request({
    url: '/activity/updateomit.zepc',
    method: 'post',
    data: {
      AcId: id
    }
  })
}

// 导出验证码
export function exportCodeList(id) {
  return request({
    url: '/activity/derivecode.zepc',
    method: 'post',
    data: {
      AcId: id
    }
  })
}

/**
 * 待审批、编辑、审批未通过活动状态列表（管理员）
 * state = 1 待审批
 * state = 2 编辑
 * state = 3 未通过审批
 */
export function getAdminVeifyList(_data) {
  const data = Object.assign({ sort: '1' }, _data)
  return request({
    url: '/activity/AcState.zepc',
    method: 'post',
    data
  })
}

// 获取所有待审批的活动列表
export function getAllVerifyList(_data) {
  const data = Object.assign({ sort: '4' }, _data)
  return request({
    url: '/activity/AcState.zepc',
    method: 'post',
    data
  })
}

// 获取管理员的全部活动列表
export function getAdminAllList(data) {
  return request({
    url: '/activity/adminAllAc.zepc',
    method: 'post',
    data
  })
}

export function getAdminEditList(_data) {
  const data = Object.assign({ sort: '2' }, _data)
  return request({
    url: '/activity/AcState.zepc',
    method: 'post',
    data
  })
}

export function getAdminFailList(_data) {
  const data = Object.assign({ sort: '3' }, _data)
  return request({
    url: '/activity/AcState.zepc',
    method: 'post',
    data
  })
}

// 查看全部审核未通过活动
export function getAllFailList(_data) {
  const data = Object.assign({ sort: '5' }, _data)
  return request({
    url: '/activity/AcState.zepc',
    method: 'post',
    data
  })
}

// 活动验证码认证
export function verifyCode(AcId, code) {
  return request({
    url: '/activity/updateHdCode.zepc',
    method: 'post',
    data: {
      AcId,
      code
    }
  })
}

// 管理员生成活动验证码
export function generateActivityCode(AcId) {
  return request({
    url: '/activity/getHdCode.zepc',
    method: 'post',
    data: { AcId }
  })
}

// 活动提交审核
export function sendToVerify(AcId) {
  return request({
    url: '/activity/updatemite.zepc',
    method: 'post',
    data: { AcId }
  })
}

// 活动提交审核
export function publishActivity(AcId, state, opinion) {
  const data = { AcId, state }
  if (opinion) {
    data.opinion = opinion
  }

  return request({
    url: '/activity/updatesubmit.zepc',
    method: 'post',
    data
  })
}

// 生成活动验证码
export function genActivityCode(AcId) {
  return request({
    url: '/activity/getHdCode.zepc',
    method: 'post',
    data: { AcId }
  })
}

// 学生获取活动验证码
// export function getActivityCode(AcId) {
//   return request({
//     url: '/activity/updateQickMark.zepc',
//     method: 'post',
//     data: { AcId }
//   })
// }

// 管理员获取活动验证码
export function getAdminActivityCode(AcId) {
  return request({
    url: '/activity/updatemark.zepc',
    method: 'post',
    data: { AcId }
  })
}

// 验证活动二维码
export function verifyActivityQrCode(AcId, code) {
  return request({
    url: '/activity/updateQickMark.zepc',
    method: 'post',
    data: { AcId, s: code }
  })
}

// 验证活动验证码
export function verifyActivityCode(AcId, code) {
  return request({
    url: '/activity/updateHdCode.zepc',
    method: 'post',
    data: { AcId, code }
  })
}

// 增加活动附加分
export function addScore({ AcId, userid, acaddscore, addscoreexplain }) {
  return request({
    url: '/activity/updateAttempts.zepc',
    method: 'post',
    data: { AcId, userid, acaddscore, addscoreexplain }
  })
}

// Excel导入快捷活动学分
export function importFastScore(formdata, AcId) {
  return request({
    url: 'activity/importsorce.zepc',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data' // 之前说的以表单传数据的格式来传递fromdata
    },
    data: formdata,
    params: { AcId }
  })
}

// Excel导入快捷活动学分
export function batchAddonScore(formdata, AcId) {
  return request({
    url: 'activity/importAttempts.zepc',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: formdata,
    params: { AcId }
  })
}

// 活动活动报名人员名单
export function getsignInUserList(data) {
  return request({
    url: '/score/sel_willnum.zepc',
    method: 'post',
    data
  })
}

// 获取系部班级信息
export function getClassData() {
  return request({
    url: '/activity/queryall.zepc',
    method: 'post',
    data: {}
  })
}
